import { Card, Form, Input, InputNumber, Button } from 'antd';
import { useSettingsStore } from '@/stores/settings';

export default function Settings() {
  const [form] = Form.useForm();
  const { settings, updateSettings } = useSettingsStore();

  const handleSubmit = (values: any) => {
    updateSettings(values);
  };

  return (
    <Card title="OpenAI 设置">
      <Form
        form={form}
        layout="vertical"
        initialValues={settings}
        onFinish={handleSubmit}
      >
        <Form.Item
          name="baseUrl"
          label="Base URL"
          rules={[{ required: true, message: '请输入 Base URL' }]}
        >
          <Input placeholder="https://api.openai.com/v1" />
        </Form.Item>

        <Form.Item
          name="apiKey"
          label="API Key"
          rules={[{ required: true, message: '请输入 API Key' }]}
        >
          <Input.Password placeholder="sk-..." />
        </Form.Item>

        <Form.Item
          name="model"
          label="模型"
          rules={[{ required: true, message: '请选择模型' }]}
        >
          <Input placeholder="gpt-3.5-turbo" />
        </Form.Item>

        <Form.Item
          name="temperature"
          label="温度"
          rules={[{ required: true, message: '请输入温度值' }]}
        >
          <InputNumber min={0} max={2} step={0.1} />
        </Form.Item>

        <Form.Item>
          <Button type="primary" htmlType="submit">
            保存设置
          </Button>
        </Form.Item>
      </Form>
    </Card>
  );
} 